"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HubSpotConfigError = void 0;
const config_1 = require("../constants/config");
const lang_1 = require("../utils/lang");
const NAME = 'HubSpotConfigError';
const OPERATION_TEXT = {
    [config_1.HUBSPOT_CONFIG_OPERATIONS.READ]: 'reading',
    [config_1.HUBSPOT_CONFIG_OPERATIONS.WRITE]: 'writing to',
    [config_1.HUBSPOT_CONFIG_OPERATIONS.DELETE]: 'deleting',
};
function isEnvironmentError(type) {
    return type === config_1.HUBSPOT_CONFIG_ERROR_TYPES.INVALID_ENVIRONMENT_VARIABLES;
}
class HubSpotConfigError extends Error {
    type;
    operation;
    constructor(message, type, operation, options) {
        const configType = isEnvironmentError(type)
            ? 'environment variables'
            : 'file';
        const operationText = OPERATION_TEXT[operation];
        const withBaseMessage = (0, lang_1.i18n)('models.HubSpotConfigError.baseMessage', {
            configType,
            message: message ? `: ${message}` : '',
            operation: operationText,
        });
        super(withBaseMessage, options);
        this.name = NAME;
        this.type = type;
        this.operation = operation;
    }
}
exports.HubSpotConfigError = HubSpotConfigError;
